<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%@page language="java" contentType="text/html; charset=ISO-8859-1"
	pageEncoding="ISO-8859-1"%>
	
<%@page import="java.util.Date"%>
<%@ page import="java.sql.*" %>
<%@ page import="java.io.*" %>
<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
<!-- RichFaces tag library declaration -->
<%@ taglib uri="http://richfaces.org/rich" prefix="rich"%>

<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>update</title>

<link href="default.css" rel="stylesheet" type="text/css" media="screen" />
</head>
<body>
<!-- start header -->
<div id="header">
	<div id="logo">
		<h1><a href="#"><span></span> update</a></h1>
		
	</div>
	<div id="menu">
		<ul id="main">
			<li class="current_page_item"><a href="Homepage.faces">HOME PAGE</a></li>
			<li><a href="#">VIEW PROFILE</a></li>
			<li><a href="#">LOG OUT</a></li>
			<li><a href="#">ADD SUB-ADMIN</a></li>
			</ul>
		
	</div>
	
</div>

<div id="wrapper">
			<!-- start page -->
			<div id="page">
				
				
				
				<div id="sidebar1" class="sidebar">
						
			
				
				
				
				
				
					<ul style="width: 551px; font-size: 400px">
					<li style="width: 170px; height: 770px">
					<h2>SUB-ADMIN</h2> </li>
						<f:view>
							
					
					
					<h:panelGrid columns="2" columnClasses="cols,cols" width="300">			
					
									<rich:panelMenu style="width: 170px" mode="ajax" iconExpandedGroup="disc" iconCollapsedGroup="disc" iconExpandedTopGroup="chevronUp" iconGroupTopPosition="right" iconCollapsedTopGroup="chevronDown">
        <rich:panelMenuGroup label="CANTEEN">
    
        <rich:panelMenuItem label="MAIN CANTEEN"><f:param name="current" value="HOME" />
        </rich:panelMenuItem>
        <rich:panelMenuItem label="MID-TOWN CANTEEN">
        <f:param name="current" value="MENU ITEM" /></rich:panelMenuItem>
        <rich:panelMenuItem label="SIBACA CANTEEN"><f:param name="current" value="COMPLAIN" />
        </rich:panelMenuItem>
        <rich:panelMenuItem label="HM CANTEEN"><f:param name="current" value="STAFF DETAIL" /></rich:panelMenuItem>
        </rich:panelMenuGroup>
        
        <rich:panelMenuGroup label="HOSTEL">
    
        <rich:panelMenuItem label="1"><f:param name="current" value="HOME" />
        </rich:panelMenuItem>
        <rich:panelMenuItem label="2">
        <f:param name="current" value="MENU ITEM" /></rich:panelMenuItem>
        <rich:panelMenuItem label="3"><f:param name="current" value="COMPLAIN" />
        </rich:panelMenuItem>
        <rich:panelMenuItem label="4"><f:param name="current" value="STAFF DETAIL" /></rich:panelMenuItem>
        </rich:panelMenuGroup>
        
       <rich:panelMenuGroup label="HOSPITAL">
    
        <rich:panelMenuItem label="1"><f:param name="current" value="HOME" />
        </rich:panelMenuItem>
        <rich:panelMenuItem label="2">
        <f:param name="current" value="MENU ITEM" /></rich:panelMenuItem>
        <rich:panelMenuItem label="3"><f:param name="current" value="COMPLAIN" />
        </rich:panelMenuItem>
        <rich:panelMenuItem label="4"><f:param name="current" value="STAFF DETAIL" /></rich:panelMenuItem>
        </rich:panelMenuGroup>
        
        <rich:panelMenuGroup label="SECURITY">
    
        <rich:panelMenuItem label="1"><f:param name="current" value="HOME" />
        </rich:panelMenuItem>
        <rich:panelMenuItem label="2">
        <f:param name="current" value="MENU ITEM" /></rich:panelMenuItem>
        <rich:panelMenuItem label="3"><f:param name="current" value="COMPLAIN" />
        </rich:panelMenuItem>
        <rich:panelMenuItem label="4"><f:param name="current" value="STAFF DETAIL" /></rich:panelMenuItem>
        </rich:panelMenuGroup>
        
        <rich:panelMenuGroup label="COLLAGE">
    
        <rich:panelMenuItem label="1"><f:param name="current" value="HOME" />
        </rich:panelMenuItem>
        <rich:panelMenuItem label="2">
        <f:param name="current" value="MENU ITEM" /></rich:panelMenuItem>
        <rich:panelMenuItem label="3"><f:param name="current" value="COMPLAIN" />
        </rich:panelMenuItem>
        <rich:panelMenuItem label="4"><f:param name="current" value="STAFF DETAIL" /></rich:panelMenuItem>
        </rich:panelMenuGroup>
        
        <rich:panelMenuGroup label="SHOPPING CENTER">
    
        <rich:panelMenuItem label="1"><f:param name="current" value="HOME" />
        </rich:panelMenuItem>
        <rich:panelMenuItem label="2">
        <f:param name="current" value="MENU ITEM" /></rich:panelMenuItem>
        <rich:panelMenuItem label="3"><f:param name="current" value="COMPLAIN" />
        </rich:panelMenuItem>
        <rich:panelMenuItem label="4"><f:param name="current" value="STAFF DETAIL" /></rich:panelMenuItem>
        </rich:panelMenuGroup>
        
        <rich:panelMenuGroup label="HOTEL">
    
        <rich:panelMenuItem label="1"><f:param name="current" value="HOME" />
        </rich:panelMenuItem>
        <rich:panelMenuItem label="2">
        <f:param name="current" value="MENU ITEM" /></rich:panelMenuItem>
        <rich:panelMenuItem label="3"><f:param name="current" value="COMPLAIN" />
        </rich:panelMenuItem>
        <rich:panelMenuItem label="4"><f:param name="current" value="STAFF DETAIL" /></rich:panelMenuItem>
        </rich:panelMenuGroup>
        
        <rich:panelMenuGroup label="MESS">
    
        <rich:panelMenuItem label="1"><f:param name="current" value="HOME" />
        </rich:panelMenuItem>
        <rich:panelMenuItem label="2">
        <f:param name="current" value="MENU ITEM" /></rich:panelMenuItem>
        <rich:panelMenuItem label="3"><f:param name="current" value="COMPLAIN" />
        </rich:panelMenuItem>
        <rich:panelMenuItem label="4"><f:param name="current" value="STAFF DETAIL" /></rich:panelMenuItem>
        </rich:panelMenuGroup>
        
        <rich:panelMenuGroup label="SALOON">
    
        <rich:panelMenuItem label="1"><f:param name="current" value="HOME" />
        </rich:panelMenuItem>
        <rich:panelMenuItem label="2">
        <f:param name="current" value="MENU ITEM" /></rich:panelMenuItem>
        <rich:panelMenuItem label="3"><f:param name="current" value="COMPLAIN" />
        </rich:panelMenuItem>
        <rich:panelMenuItem label="4"><f:param name="current" value="STAFF DETAIL" /></rich:panelMenuItem>
        </rich:panelMenuGroup>
        
       <rich:panelMenuGroup label="DOM">
    
        <rich:panelMenuItem label="1"><f:param name="current" value="HOME" />
        </rich:panelMenuItem>
        <rich:panelMenuItem label="2">
        <f:param name="current" value="MENU ITEM" /></rich:panelMenuItem>
        <rich:panelMenuItem label="3"><f:param name="current" value="COMPLAIN" />
        </rich:panelMenuItem>
        <rich:panelMenuItem label="4"><f:param name="current" value="STAFF DETAIL" /></rich:panelMenuItem>
        </rich:panelMenuGroup>
        
        <rich:panelMenuGroup label="CANTEEN">
    
        <rich:panelMenuItem label="MAIN CANTEEN"><f:param name="current" value="HOME" />
        </rich:panelMenuItem>
        <rich:panelMenuItem label="MID-TOWN CANTEEN">
        <f:param name="current" value="MENU ITEM" /></rich:panelMenuItem>
        <rich:panelMenuItem label="SIBACA CANTEEN"><f:param name="current" value="COMPLAIN" />
        </rich:panelMenuItem>
        <rich:panelMenuItem label="HM CANTEEN"><f:param name="current" value="STAFF DETAIL" /></rich:panelMenuItem>
        </rich:panelMenuGroup>
        
        <rich:panelMenuGroup label="CANTEEN">
    
        <rich:panelMenuItem label="MAIN CANTEEN"><f:param name="current" value="HOME" />
        </rich:panelMenuItem>
        <rich:panelMenuItem label="MID-TOWN CANTEEN">
        <f:param name="current" value="MENU ITEM" /></rich:panelMenuItem>
        <rich:panelMenuItem label="SIBACA CANTEEN"><f:param name="current" value="COMPLAIN" />
        </rich:panelMenuItem>
        <rich:panelMenuItem label="HM CANTEEN"><f:param name="current" value="STAFF DETAIL" /></rich:panelMenuItem>
        </rich:panelMenuGroup>
        
       </rich:panelMenu>
 
				
		
		
         <rich:panel bodyClass="rich-laguna-panel-no-header" style="width: 99%">
       <rich:tabPanel style="width: 200px" switchType="client" selectedTab="MENU">
           
        <rich:tab label="MENU" style="width: 580px">
           
            
  
  <FORM action="Update.faces" method="get">
    <TABLE style="background-color: #ECE5B6;" WIDTH="30%" >
    
      <TR>
	      <TH width="50%">Number:</TH>
		  <TD width="50%"><INPUT TYPE="text" NAME="no"></TD>
	  </tr>
      <TR>
	     <TH width="50%">Name:</TH>
		 <TD width="50%"><INPUT TYPE="text" NAME="name"></TD>
	  </tr>
	  <TR>
	     <TH width="50%">Price:</TH>
		 <TD width="50%"><INPUT TYPE="text" NAME="price"></TD>
	  </tr>
	  <TR>
	     <TH width="50%">Type:</TH>
		 <TD width="50%"><INPUT TYPE="text" NAME="type"></TD>
	  </tr>
	  <TR>
	     <TH width="50%">To Update</TH>
		 <TD width="50%"><INPUT TYPE="text" NAME="no"></TD>
	  </tr>
	  <TR>
	      <TH></TH>
		  <TD width="50%"><INPUT TYPE="submit" VALUE="submit"></TD>
	  </tr>
   </TABLE>
<%
   String name = request.getParameter("no");
   String city = request.getParameter("name");
   String phone = request.getParameter("price");
   String phone1 = request.getParameter("type");
String phone2 = request.getParameter("no");

   /* Create string of connection url within specified format with machine name, 
    port number and database name. Here machine name id localhost and database name is student. */
    String connectionURL = "jdbc:postgresql://localhost/mainmenu";

    // declare a connection by using Connection interface 
    Connection connection = null;

    // declare object of Statement interface that uses for executing sql statements.
     PreparedStatement pstatement = null;

	// Load JBBC driver "com.mysql.jdbc.Driver"
     Class.forName("org.postgresql.Driver").newInstance();

     int updateQuery = 0;
     
	 // check if the text box is empty
	 if(name!=null && city!=null && phone!=null){

		 // check if the text box having only blank spaces
	     if(name!="" && city!="" && phone!="") {

            try {
              /* Create a connection by using getConnection() method that takes 
			  parameters of string type connection url, user name and password to connect 
			  to database. */
              connection = DriverManager.getConnection(connectionURL, "clair", "clair");

              // sql query to insert values in the secified table.
              String queryString = "update  menu set no='"+name+"' , name='"+city+"' , price='"+phone+"', type='"+phone1+"' where no='"+phone2+"'";

			 /* createStatement() is used for create statement object that is used for 
			   sending sql statements to the specified database. */
              pstatement = connection.prepareStatement(queryString);
              
              updateQuery = pstatement.executeUpdate();

              if (updateQuery != 0) { %>
			    <br>
			    <TABLE style="background-color: #E3E4FA;" WIDTH="30%" border="1">
			        <tr><th>Data is  successfully updated in database.</th></tr>
				</table>
<%
              }
            } 
            catch (Exception ex) {
            out.println("Unable to connect to batabase.");
   
            }
            finally {
                // close all the connections.
                pstatement.close();
                connection.close();
            }
	     }
	   }
%>
 
 
<h1> <a href="hmcanteen.faces">Return</a></h1>
  </FORM>
<font></font>  
      
            
            
            
            
            </rich:tab>
            
    </rich:tabPanel>
    </rich:panel>
      
       </h:panelGrid>
       
       
       
						</f:view>
						<!-- start sidebars -->
		
				
					
		
		</ul></div><div id="sidebar2" class="sidebar">
						
			<ul>
				<li>
					<h2>Key Milestones:</h2>
					<ul>
						<li><a href="#">Last Date for Campus Registration.</a></li>
						<li><a href="#">Important Dates.</a></li>
						<li><a href="#">Result of Engg. College.</a></li>
						<li><a href="#">Stroke 2012.</a></li>
						<li><input type="submit" name="AddKeyMilestone" value="ADD"> </li>
					</ul>
					 
				</li>
				
				<li>
					<h2>Recent Posts:</h2>
					<ul>
						<li><a href="#">Update 1</a> </li>
						<li><a href="#">Update 2</a></li>
						<li><a href="#">Update 3</a></li>
						<li><a href="#">Update 4</a></li>
						<li><input type="submit" name="AddKeyMilestone" value="ADD"> </li>
					</ul>
				</li><li></li>		</ul>
		</div>
				
						
		
		

				</div>
				<!-- end page -->
				
			</div>
			<div id="footer">
	<p class="copyright">&copy;&nbsp;&nbsp;2011 All Rights Reserved &nbsp;&bull;&nbsp; Design by SIT2</p>
				<p class="link"><a href="#">Privacy Policy</a>&nbsp;&#8226;&nbsp;<a href="#">Terms of Use</a></p>
			</div>
		
</body>
</html>

